package com.yunfeisoft.business.service.impl;

import com.yunfeisoft.business.dao.inter.ElderOrganFunctionDao;
import com.yunfeisoft.business.model.ElderOrganFunction;
import com.yunfeisoft.business.service.inter.ElderOrganFunctionService;
import com.yunfeisoft.common.base.BaseServiceImpl;
import com.yunfeisoft.common.sql.separation.DataSourceChange;
import com.yunfeisoft.common.utils.Page;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import sun.awt.image.ImageWatched;

import java.util.Map;

/**
 * ClassName: ElderOrganFunctionServiceImpl
 * Description: 脏器功能从表service实现
 * Author: Jackie liu
 * Date: 2020-04-04
 */
@Service("elderOrganFunctionService")
public class ElderOrganFunctionServiceImpl extends BaseServiceImpl<ElderOrganFunction, String, ElderOrganFunctionDao> implements ElderOrganFunctionService {

    @Override
    @DataSourceChange(slave = true)
    public Page<ElderOrganFunction> queryPage(Map<String, Object> params) {
        return getDao().queryPage(params);
    }

    @Override
    public ElderOrganFunction getByHealthId(String elderHealthId) {
        return getDao().getByHealthId(elderHealthId);
    }

    @Override
    public void deleteByHealthId(String elderHealthId) {
        getDao().deleteByHealthId(elderHealthId);
    }

    @Transactional
    public void saveElderOrganFunction(ElderOrganFunction record) {
        // 删除之前的记录
        getDao().deleteByHealthId(record.getElderHealthId());
        getDao().insert(record);
    }
}